#include <my_head.h>

int main(int argc, const char *argv[]){
    int fd_r = open("hello.txt", O_RDONLY);
    int fd_w = open("hello2.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
    pid_t pid = 0;
    char buff[5] = {0};
    if(-1 == (pid = fork())){
        ERR_LOG("fork error");
    }else if(0 < pid){ // 父
        sleep(1);
        read(fd_r, buff, 4);
        printf("父:buff = [%s]\n", buff); // 5678
    }else if(0 == pid){// 子
        read(fd_r, buff, 4);
        printf("子:buff = [%s]\n", buff); // 1234
    }
    return 0;
}